package no.rmz.chez.game.moveSelection;

import java.util.Collection;
import java.util.List;


public final class RandomSelector<T> extends Selector<T> {
    
    /**
     * Select a randomly chosen element in the collection.
     * @param possibilities
     * @return An element.
     */
    @Override
    public T selectFrom(final Collection<T> possibilities) {
        final List<T> l = asList(possibilities);
        return l.get(getRandom().nextInt(l.size() - 1));
    }
}
